package com.atguigu.security.custom;

/**
 * ClassName: CustomMd5PasswordEncoder
 * Package: com.atguigu.security.custom
 * Description:
 *
 * @Author 蹇泽阳
 * @Create 2023/11/18 17:56
 * @Version 1.0
 */

import com.atguigu.common.util.MD5;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

/**
 * <p>
 * 密码处理
 * </p>
 */
@Component
public class CustomMd5PasswordEncoder implements PasswordEncoder {
  
  
  @Override
  public String encode(CharSequence rawPassword) {
    return MD5.encrypt(rawPassword.toString());
  }
  
  @Override
  public boolean matches(CharSequence rawPassword, String encodedPassword) {
    return encodedPassword.equals(MD5.encrypt(rawPassword.toString()));
  }
}
